package com.test.rabbitmq.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


/**
 * @ClassName WorkReciveListener
 * @Author lulei
 * @Data 2020/3/13 19:52
 */

/**
 * @RabbitListener(queues = "queue-NO:10001") 可以修饰类和方法
 *
 */
@Component
@RabbitListener(queues = "queue-NO:10001")
public class WorkReciveListener {

    @RabbitHandler
    public void getMassage(String data, Channel channel, Message message2) throws Exception{

        System.out.println("================"+message2.getMessageProperties().getDeliveryTag());
        channel.basicAck(message2.getMessageProperties().getDeliveryTag(),false);

        System.out.println("---"+data);




    }
}
